﻿<div id="wrap">
    <div data-ng-include src="'views/shared/_nav.html'"></div>
    <div data-ng-include src="'views/shared/_navusers.html'"></div>
    <div class="container admin-views-main admin-views-users-index" data-ng-controller="UsersController">
        <form id="form" action="">
            <div id="modal-user-edit" class="modal fade">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i></button>
                            <h4 class="modal-title">{{editItem.UserName ? editItem.UserName : lbl.addNewUser}}</h4>
                        </div>
                        <div class="modal-body">
                            <div id="frm-user-edit" class="form-horizontal clearfix">
                                <div class="form-group">
                                    <label class="control-label col-md-4" for="txtUserName">{{lbl.name}}</label>
                                    <div class="col-md-8">
                                        <input type="text" id="txtUserName" name="txtUserName" class="form-control" data-ng-model="editItem.UserName" ng-disabled="!isNewItem" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-4" for="txtEmail">{{lbl.email}}</label>
                                    <div class="col-md-8">
                                        <input type="text" id="txtEmail" name="txtEmail" class="form-control ltr-dir" data-ng-model="editItem.Email" />
                                    </div>
                                </div>
                                <div class="form-group" data-ng-if="isNewItem">
                                    <label class="control-label col-md-4" for="txtPassword">{{lbl.password}}</label>
                                    <div class="col-md-8">
                                        <input type="password" class="form-control ltr-dir" id="txtPassword" name="txtPassword" data-ng-model="editItem.Password" />
                                    </div>
                                </div>
                                <div class="form-group" data-ng-if="isNewItem">
                                    <label class="control-label col-md-4" for="txtConfirmPassword">{{lbl.confirmPassword}}</label>
                                    <div class="col-md-8">
                                        <input type="password" class="form-control ltr-dir" id="txtConfirmPassword" name="txtConfirmPassword" />
                                    </div>
                                </div>
                                <br />
                                <h4>{{lbl.roles}}</h4>
                                <hr />
                                <div class="col-md-offset-4 col-md-8">
                                    <div class="checkbox" data-ng-repeat="role in roles">
                                        <label>
                                            <input type="checkbox" data-ng-model="role.IsChecked" /> {{role.RoleName}}
                                        </label>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button data-ng-click="saveUser()" class="btn btn-primary pull-right btn-tabkey"><i class="fa fa-save"></i>{{lbl.save}}</button>
                            <button type="button" class="btn btn-default" data-dismiss="modal"><i class="fa fa-ban"></i>{{lbl.cancel}}</button>
                        </div>
                    </div>
                </div>
            </div>
            <div class="page-header clearfix">
                <h2 class="page-title pull-left">
                    {{lbl.users}} <span id="spinner" class="loaded"><i class="fa fa-spinner fa-spin fa-sm"></i></span>
                </h2>
                <button data-ng-click="loadEditForm()" class="btn btn-success btn-header pull-right" type="button"><i class="fa fa-plus"></i>{{lbl.addNewUser}}</button>
            </div>
            <div class="toolbar-grid clearfix">
                <div class="pull-left">
                    <span data-ng-click="processChecked('delete')" class="btn btn-danger btn-sm"><i class="fa fa-times"></i>{{lbl.doDelete}}</span>
                </div>
                <div class="filterbar pull-right">
                    <input type="text" data-ng-model="query" data-ng-change="search()" class="input-sm form-control search-grid pull-right" placeholder="{{lbl.search}}" />
                </div>
            </div>
            <table class="table table-bordered table-striped table-hover table-responsive">
                <thead>
                    <tr>
                        <th><input type="checkbox" id="chkAll" data-ng-click="checkAll($event)" /></th>
                        <th class="table-item-title table-item-w90">{{lbl.title}} <a data-ng-click="sort_by('UserName',$event)"><i class="fa fa-sort"></i></a></th>
                        <th>{{lbl.roles}}</th>
                        <th class="hmax479">{{lbl.email}}</th>
                    </tr>
                </thead>
                <tbody>
                    <tr data-ng-repeat="item in pagedItems[currentPage] | orderBy:sortingOrder:reverse">
                        <td><input type="checkbox" id="cb-{{item.UserName}}" data-ng-model="item.IsChecked" /> </td>
                        <td class="table-item-title"><a title="{{item.UserName}}" href="" ng-click="loadEditForm(item.UserName)">{{item.UserName}}</a></td>
                        <td><span ng-repeat="r in item.Roles"> <a href="{{SiteVars.RelativeWebRoot}}admin/#/users/roles?id={{r.RoleName}}">{{r.RoleName}}</a> </span> </td>
                        <td class="hmax479">{{item.Email}}</td>
                    </tr>
                </tbody>
            </table>
            <div class="text-right pagination-wrapper">
                <ul class="pagination pagination-sm">
                    <li data-ng-class="{disabled: currentPage == 0}">
                        <a data-ng-click="prevPage()">« {{lbl.prev}}</a>
                    </li>
                    <li data-ng-repeat="n in range(pagedItems.length)" data-ng-class="{active: n == currentPage}" data-ng-click="setPage()">
                        <a data-ng-bind="n + 1">1</a>
                    </li>
                    <li data-ng-class="{disabled: currentPage == pagedItems.length - 1}">
                        <a data-ng-click="nextPage()">{{lbl.next}} »</a>
                    </li>
                </ul>
            </div>
        </form>
    </div>
</div>
<div id="footer" data-ng-include src="'views/shared/_footer.html'"></div>